﻿/// <reference path="../Common/duomi.common.js" />
/// <reference path="../Common/duomi.common.ajax.js" />
/// <reference path="../Common/duomi.extend.remote.ajax.js" />
Namespace.register("DuoMi.Controls.RemoteList");
(function () {
    DuoMi.Controls.RemoteList = {
        $description: '远程(跨域)调用接口加载列表',
        $author: 'Ming.ma',
        $version: '1.0.0',
        init: function (obj, option) { return initList(obj, option); }
    };

    function initList(obj, option) {
        //缺省配置
        var defaultOption = {
            url: 'http://www.baidu.com',
            data: { a: 1, b: 2 },
            type: 'get',
            encoding: 'UTF-8',
            async: true,
            success: function (t) {
                alert(t)
            },
            error: function (e) {
                alert(e)
            }
        };
        var _option = leftCopyJson(defaultOption, option);
        $ext.remote.majax.ajax(_option);
    }

    function leftCopyJson(jsn1, jsn2) {
        var jsn = {};
        for (var j in jsn1) {
            jsn[j] = $object.isNull(jsn2[j]) ? jsn1[j] : jsn2[j];
        }
        return jsn;
    }
})();